package com.example.controller;

import com.example.entity.Student;
import com.example.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Create with Intellij idea
 * User:鲁智明
 * Date:2018/10/15
 * Time:9:46
 */
@RestController
public class UserController {
    @Autowired
    private StudentService studentService;
    @Resource
    private CacheManager cacheManager;


    @RequestMapping("/findById")
    public Student findById(int id){
        return studentService.findById(id);
    }

    //清除缓存
    @RequestMapping("/removeCache")
    public void removeCache(){
        cacheManager.getCache("studentCache").clear();
    }
}
